import Vue from "vue";
import Vuex from "vuex";
import createPersistedstate from "vuex-persistedstate";
Vue.use(Vuex);

export default new Vuex.Store({
    state: {
        profile: {}, //用户信息
        token: "", //登录权限
        flag: true,
    },
    mutations: {
        setUser(state, user) {
            state.profile = user;
        },
        setToken(state, token) {
            state.token = token;
        },
    },
    getters: {
        getToken(state) {
            return state.token;
        },
    },
    actions: {},
    modules: {},
    plugins: [
        createPersistedstate({
            key: "xiaotu",
        }),
    ],
});